package com.dt76.smallloanbackendservice.controller.zjs;


import com.dt76.smallloanbackendservice.pojo.zjs.User;

import com.dt76.smallloanbackendservice.service.zjs.UserService;
import com.dt76.smallloanbackendservice.utils.Page;
import com.dt76.smallloanbackendservice.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/zjs")
public class UserController {

    @Autowired
    private UserService userService;
    @RequestMapping("/qryUser")
    @ResponseBody
    public List<User> qryAllBlackUser(){return userService.qryAllUser();}

    @RequestMapping("/qryPageUserAll")
    @ResponseBody
    public Page qryPageAllBlackUser(@RequestParam("pageIndex") int pageIndex,
                                    @RequestParam("queryname")String queryname,
                                    @RequestParam("userId")int userId,
                                    @RequestParam("queryTime")String queryTime
    ){
        return userService.qryPageAllUser(pageIndex,queryname,userId,queryTime); }
    @RequestMapping("/delUser")
    @ResponseBody
    public Result delBlackUser(@RequestParam("userId")int userId ){

        System.out.println("进入删除方法");
        try {
            userService.delUser(userId);
            return new Result(true,"删除成功>>>");
        } catch (Exception e) {
            return new Result(false,"删除失败>>>");
        }

    }

}
